#include <stdio.h>

int main (void)

{
	int m,n,r;
	scanf("%d,%d",&m,&n);
	while(r != 0)
	{
		r= m%n;
		m=n;
		n=r;
	}
	printf("%d",m);
	return 0;
}